home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / dosrcss.zip / RCSKEYS.C < prev    next >
C/C++ Source or Header  |  1990-07-18  |  3KB  |  103 lines

  1. /*
  2.  *                     RCS keyword table and match operation
  3.  */
  4. #ifndef lint
  5. static char rcsid[]= "$Id: rcskeys.c,v 5.2 90/07/15 11:34:13 ROOT_DOS Release $ Purdue CS";
  6. #endif
  7.  
  8. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  9.    Distributed under license by the Free Software Foundation, Inc.
  10.  
  11. This file is part of RCS.
  12.  
  13. RCS is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 1, or (at your option)
  16. any later version.
  17.  
  18. RCS is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with RCS; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. Report problems and direct all questions to:
  28.  
  29.     rcs-bugs@cs.purdue.edu
  30.  
  31. */
  32.  
  33.  
  34.  
  35. /* $Log:    rcskeys.c,v $
  36.  * Revision 5.2  90/07/15  11:34:13  ROOT_DOS
  37.  * DOS version of RCS 4.0 checked in for MODS
  38.  * by lfk@athena.mit.edu
  39.  * Also update to MSC 6.0
  40.  * 
  41.  * Revision 4.3  89/05/01  15:13:02  narten
  42.  * changed copyright header to reflect current distribution rules
  43.  * 
  44.  * Revision 4.2  87/10/18  10:36:33  narten
  45.  * Updating version numbers. Changes relative to 1.1 actuallyt
  46.  * relative to 4.1
  47.  * 
  48.  * Revision 1.2  87/09/24  14:00:10  narten
  49.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  50.  * warnings)
  51.  * 
  52.  * Revision 1.1  84/01/23  14:50:32  kcs
  53.  * Initial revision
  54.  * 
  55.  * Revision 4.1  83/05/04  10:06:53  wft
  56.  * Initial revision.
  57.  * 
  58.  */
  59.  
  60.  
  61. #include "rcsbase.h"
  62.  
  63.  
  64.  
  65. struct { char * keyword; enum markers marker;} markertable[] =
  66.         {{AUTHOR,   Author  },
  67.          {DATE,     Date    },
  68.          {HEADER,   Header  },
  69.          {IDH,      Id      },
  70.          {LOCKER,   Locker  },
  71.          {LOG,      Log     },
  72.          {RCSFILE,  RCSfile },
  73.          {REVISION, Revision},
  74.          {SOURCE,   Source  },
  75.          {STATE,    State   },
  76.          {nil,      Nomatch }};
  77.  
  78.  
  79.  
  80. enum markers trymatch(string,onlyvdelim)
  81. char * string;
  82. /* function: Checks whether string starts with a keyword followed
  83.  * by a KDELIM or a VDELIM. If onlyvdelim==true, only a VDELIM
  84.  * may follow the keyword.
  85.  * If successful, returns the appropriate marker, otherwise Nomatch.
  86.  */
  87. {
  88.         register int j;
  89.     register char * p, * s;
  90.         for (j=0; markertable[j].keyword!=nil; j++ ) {
  91.         /* try next keyword */
  92.         p = markertable[j].keyword; s = string;
  93.         while (*p!='\0' && *s!='\0' && *p == *s) {
  94.             p++; s++;
  95.         }
  96.         if (*p != '\0') continue; /* no match */
  97.         if ((*s == VDELIM) || (!onlyvdelim && (*s == KDELIM)))
  98.             return(markertable[j].marker);
  99.         }
  100.         return(Nomatch);
  101. }
  102.  
  103.